# -*- coding: utf-8 -*-
# @Time    : 2024/1/4 21:50
# @Author  : micah
# @File    : 16.携带json数据.py
# @Software: PyCharm

"""
通过requests可以发送post请求, 发送post请求之前需要在浏览器的载荷中查看需要发送的数据
    发送的数据是表单数据
"""

import requests

headers = {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
    'Referer': 'https://careers.aliyun.com/off-campus/position-list?lang=zh',
    'Cookie': 'XSRF-TOKEN=89565981-db73-4315-aeb4-86ed3c152d29; SESSION=NkVFN0QxMTI5MUM0NDVGQjIxMUEzNkEzOTBDNTI0QUE=; cna=zaYdHuzI0wICAa8A4YxQCVJU; arms_uid=7e2456ed-3381-4880-b131-5e09922b318b; l=fBTQlizVPAmxGVIdBOfwnurza77tGIRfguPzaNbMi9fP9N1B5JrRW1BrYS86CnGVEsWpR3yI_B6WBbTaEyz17xv9-eiZR7qYzdTHR3zQR; isg=BFJSBQ6WY3sAPJ-H9NCYsHsiox40Y1b9qDDgoxyqtIWVL_YpDvXTDDQOn4sTX86V; tfstk=eNoeSlVGeuc_oHBj8Pqz0iLih6qLYodfx0N7EYDudWVH9eUl4jM5AzYKN3-ohfaoAkMI_blqGymBJvMlqYVTNWNIR8xrsfa3V2NQE9nZggsB9eHl4uZkGItXcvBQ2uAjeZqllvFcmodBcnMKK9wHhAxXpa6ctiIYP3bc3zOmH5mM-hbA6UvYsgjox3U8gLN_BJnNOyVmKD7OWK2U8SD3_gzGwR47Z03FZaz3BRPXQdWJKL9Z1phK-aQ8SoeaGpwCyaU3GRPXQd7RyyB4QS9Qd'
}

url = 'https://careers.aliyun.com/position/search?_csrf=89565981-db73-4315-aeb4-86ed3c152d29'

json_data = {"channel": "group_official_site", "language": "zh", "batchId": "", "categories": "", "deptCodes": [],
             "key": "", "pageIndex": 1, "pageSize": 10, "regions": "", "subCategories": ""}

response = requests.post(url, headers=headers, json=json_data).json()['content']['datas']
for temp in response:
    print(temp['name'])
